<template>
	<view>
		<view class="message_top wrap dflex jcsb">
			<view class="cflex aic p_relative" @click="openFans">
				<view class="p_absolute" style="margin-right:-35px;">
					<u-badge type="error" :value='fans_count'></u-badge>
				</view>
				<image :src="domain + '/static/msg_01.png'" mode="" style="width: 90rpx; height: 90rpx"></image>
				<text class="f14 mt5">粉丝</text>
			</view>
			<view class="cflex aic p_relative" @click="openReplies">
				<view class="p_absolute" style="margin-right:-35px;">
					<u-badge type="error" :value='replies_count'></u-badge>
				</view>
				<image :src="domain + '/static/msg_02.png'" mode="" style="width: 90rpx; height: 90rpx"></image>
				<text class="f14 mt5">评论</text>
			</view>
			<view class="cflex aic p_relative" @click="openLikes">
				<view class="p_absolute" style="margin-right:-35px;">
					<u-badge type="error" :value='likes_count'></u-badge>
				</view>
				<image :src="domain + '/static/msg_03.png'" mode="" style="width: 90rpx; height: 90rpx"></image>
				<text class="f14 mt5">点赞</text>
			</view>
			<view class="cflex aic p_relative" @click="openCollections">
				<view class="p_absolute" style="margin-right:-35px;">
					<u-badge type="error" :value='collections_count'></u-badge>
				</view>
				<image :src="domain + '/static/msg_04.png'" mode="" style="width: 90rpx; height: 90rpx"></image>
				<text class="f14 mt5">收藏</text>
			</view>
		</view>
		
		<view class="line5"></view>
		
		<view class="dflex aic wrap jcsb" @click="openAnnouncement">
			<view class="message_image">
				<image src="/static/bell.png" mode="scaleToFill" style="width: 90rpx; height: 90rpx"></image>
			</view>
			<view class="cflex ml15 fg1">
				<text class="f14 fbold">系统通知</text>
				<text class="f12 ca3a3a3 mt3">暂无新消息</text>
				<text class="f10 ca3a3a3 mt3">{{ newdate }}</text>
			</view>
			<u-icon name="arrow-right" color="#ccc"></u-icon>
		</view>
		
		
		<view class="empty_list" v-if="empty" style="margin-top: 170px;">
			<u-empty mode="list" text="还没有任何消息,多多发帖互动哦~"></u-empty>
		</view>
		
		<bottomMenu></bottomMenu>
	</view>
</template>

<script>
	
	
	export default {
		data() {
			return {
				empty : false,
				notifications : [],				
				domain : uni.getStorageSync('domain'),
				fans_count : '',
				replies_count : '',
				likes_count : '',
				collections_count : '',
				newdate : uni.$u.timeFormat(new Date(), 'yyyy-mm-dd h:M:s')
			}
		},
		onLoad:function(){
			this.getAllCount();
		},
		methods: {
			getAllCount() {
				uni.showLoading({
					title:"加载中...."
				})
				uni.request({
				url:uni.getStorageSync('domain') + '/api/v1/notifications/stats',					
					method: 'GET',
					header: {
						'Accept': 'application/json',
						'Authorization' : 'Bearer ' + uni.getStorageSync('access_member_info').access_token
					},
					success: res => {
						this.fans_count = res.data.fans_unread_count
						this.replies_count = res.data.replies_unread_count
						this.likes_count = res.data.likes_unread_count
						this.collections_count = res.data.collections_unread_count
						uni.hideLoading();
					},
					fail: () => {},
					complete: () => {}
				});
			},
			openFans() {
				uni.navigateTo({
					url:"/pages/message/fans"
				})
			},
			openLikes() {
				uni.navigateTo({
					url:"/pages/message/likes"
				})
			},
			openReplies() {
				uni.navigateTo({
					url:"/pages/message/replies"
				})
			},
			openCollections() {
				uni.navigateTo({
					url:"/pages/message/collections"
				})
			},
			openAnnouncement() {
				uni.navigateTo({
					url:"/pages/message/announcement"
				})
			}
		}
	}
</script>

<style>
	.message_image {
		width: 100rpx;
		display: flex;
	}
</style>
